package com.changgou.comment.controller;

import com.changgou.comment.service.CommentService;
import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author ：周
 * @ClassName: CommentController
 * @date ：2019/8/15  15:27
 * @description ：
 * @version: 1.0
 */
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    /**
     * 添加评论信息
     * @param map
     * @return
     */
    @PostMapping("add")
    public Result add(@RequestBody Map<String ,String> map){
        commentService.add(map);
        return new Result();
    }

    /**
     * 根据spuId查询评价列表
     * @param spuId
     * @return
     */
    @GetMapping("/{spuId}")
    public Result query(@PathVariable String spuId){
        Map map = commentService.query(spuId);
        return new Result(true ,StatusCode.OK,"查询成功",map);
    }
}
